<?php

namespace Drupal\shushengyuan\Schemas;

use Drupal\shusy_banner\Entity\ShusyBannerItem;

/**
 * @OA\Schema(
 *   schema="BannerItem",
 *   type="object",
 *   description="BannerItem"
 * )
 */
class BannerItem extends AbstractBaseModel {

  protected function getEntityType() {
    return 'shusy_banner_item';
  }

  protected function setValue() {
    if ($this->entity instanceof ShusyBannerItem) {
      $value = [
        /**
         * @OA\Property(
         *   property="image",
         *   type="string",
         *   description="BANNER图片",
         * ),
         */
        'image' => $this->imageStyleUrl('BannerItemImage', file_load($this->entity->image)),
        /**
         * @OA\Property(
         *   property="link",
         *   type="string",
         *   description="跳转链接 可能为空 为空不跳转",
         * ),
         */
        'link' => $this->getBannerItemLink(),
      ];
      $this->merge($value);
    }
  }

  protected function getBannerItemLink() {
    return '';
  }
}
